<template>
  <view class="page">
    <view class="items">
      <view class="item tcard" v-for="item in list" :key="item.id">
        <!-- <view class="title">
          {{ item.companyName }}
        </view> -->
        
        <view class="tform no-border">
          <view class="tform-item">
            <view class="label">
              订单类型
            </view>
            <view class="value">
              {{ item.type === 1 ? '个检' : '团检'}}
            </view>
          </view>
          <view class="tform-item">
            <view class="label">
              体检人
            </view>
            <view class="value">
              {{userInfo.name}}
            </view>
          </view>
          <view class="tform-item">
            <view class="label">
              体检套餐
            </view>
            <view class="value">
              {{item.codename}}
            </view>
          </view>
          <view class="tform-item">
            <view class="label">
              体检时间
            </view>
            <view class="value">
              {{item.bespeak_time}}
              <!-- {{item.reserveTime.substr(0, 4) + '-' + item.reserveTime.substr(4, 2) + '-' + item.reserveTime.substr(6, 2)}} -->
            </view>
          </view>
        </view>
        <view style="padding: 0 12upx;">
          <view class="bottom">
            <view class="btn light" @click="toDetail(item)">
              查看报告
            </view>
          </view>
        </view>
        
      </view>
    </view>
  </view>
</template>

<script>
  import { mapGetters, mapActions } from 'vuex'
  import {getReportList} from '@/api/physical.js'
  export default {
    data() {
      return {
        list:[]
      }
    },
    computed:{
      ...mapGetters(['userInfo', 'userList']),
    },
    onLoad() {
      this.getReportList()
    },
    methods: {
      getReportList() {
        const data = {
          identityCard: this.userInfo.idCard
        }
        getReportList(data).then(res => {
          this.list = res
        })
      },
      toDetail(item) {
        // uni.$emit('getReportDetail', item)
        // localStorage.setItem('report', JSON.stringify(item))
        uni.setStorageSync('report', item)
        uni.navigateTo({
          // url: `./ReportDetail?report=${encodeURIComponent(JSON.stringify(item).replace(/%/g,'%25'))}`
          url: `./ReportDetail`
        })
      }
    }
  }
</script>

<style lang="scss" scoped>
  
.items {
  flex: 1;
  overflow: auto;
  .item {
    // padding: 32upx;
    .tform-item {
      padding: 12upx;
    }
    .bottom {
      display: flex;
      justify-content: flex-end;
      align-items: center;
      border-top: 1px solid rgba(0,0,0,0.12);
      padding-top: 20upx;
      .btn {
        width: 122upx;
        height: 42upx;
        background: $theme-color;
        border-radius: 42upx;
        text-align: center;
        line-height: 42upx;
        color: #FFF;
        font-size: 24upx;
      }
      .light {
        background: transparent;
        border: 1px solid $theme-color;
        color: $theme-color;
      }
    }
  }
}
</style>
